<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/12/26
  Time: 23:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>学生成绩管理系统</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.3/jquery.js"></script>
    <link rel="stylesheet" href="/static/bootstrap-4.6.2-dist/css/bootstrap.css">
    <script src="/static/bootstrap-4.6.2-dist/js/bootstrap.bundle.js"></script>
</head>
<body>
<div>
    <h1 style="margin-left: 10px;font-family: 华文楷体;font-weight: bolder">学生成绩管理系统</h1>
    <button type="button" class="btn btn-primary" onclick="openAdd()" style="margin-left: 10px">新增</button>
    <button type="button" onclick="logout()" class="btn btn-info">退出</button>
    <br>
    <br>
    <table class="table table-striped">
        <thead class="thead-dark">
        <tr>
            <th scope="col">ID</th>
            <th scope="col">姓名</th>
            <th scope="col">性别</th>
            <th scope="col">综合成绩</th>
            <th scope="col">班级</th>
            <th scope="col">年级</th>
            <th scope="col">操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="student" items="${allList}">
            <tr>
                <th scope="row">${student.id}</th>
                <td>${student.studentName}</td>
                <td>${student.gender}</td>
                <td>${student.comprehensiveAchievements}</td>
                <td>${student.studentClass}</td>
                <td>${student.studentGrade}</td>
                <td>
                    <button type="button" onclick="openEdit(${student.id})" class="btn btn-warning">编辑</button>
                    <button type="button" onclick="del(${student.id})" class="btn btn-danger">删除</button>
                </td>
            </tr>
        </c:forEach>

        </tbody>
    </table>

    <script>

        function openEdit(id) {
            console.log(id)
            location.href = "/student?operation=openEdit&id=" + id;
        }

        function openAdd() {
            location.href = "/student?operation=openAdd"
        }

        function logout() {
            location.href = "/"
        }

        function del(id) {
            console.log(id)
            confirm("确定删除吗？")
            location.href = "/student?operation=delete&id=" + id
        }

    </script>
</div>
</body>
</html>
